Skip to content

Unconstrained parameter fix#148788

Open
TomtheCoder2 wants to merge 21 commits intorust-lang:mainfrom
TomtheCoder2:unconstrained-parameter-fix
Open

Unconstrained parameter fix#148788
TomtheCoder2 wants to merge 21 commits intorust-lang:mainfrom
TomtheCoder2:unconstrained-parameter-fix

Conversation

@TomtheCoder2
Copy link
Copy Markdown

@TomtheCoder2 TomtheCoder2 commented Nov 10, 2025

View all comments

This PR is an attempt to solve the issue described in the issue #107295

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Nov 10, 2025

This PR modifies tests/ui/issues/. If this PR is adding new tests to tests/ui/issues/,
please refrain from doing so, and instead add it to more descriptive subdirectories.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 10, 2025
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Nov 10, 2025

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 11, 2025
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Nov 11, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Jan 13, 2026

☔ The latest upstream changes (presumably #150844) made this pull request unmergeable. Please resolve the merge conflicts.

@TomtheCoder2 TomtheCoder2 force-pushed the unconstrained-parameter-fix branch from de845c2 to 1f5e308 Compare March 5, 2026 01:42
@rustbot

This comment has been minimized.

@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. has-merge-commits PR has merge commits, merge with caution. labels Mar 5, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@TomtheCoder2 TomtheCoder2 requested a review from davidtwco March 8, 2026 04:20
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 8, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@TomtheCoder2 TomtheCoder2 force-pushed the unconstrained-parameter-fix branch from bbce6e5 to 06e17b4 Compare March 9, 2026 00:09
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@TomtheCoder2 TomtheCoder2 force-pushed the unconstrained-parameter-fix branch from 1747f90 to 0b83de8 Compare March 11, 2026 03:18
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 11, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Signed-off-by: janwi_mac <jan.wilhelm77@gmail.com>
@TomtheCoder2
Copy link
Copy Markdown
Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 11, 2026
Copy link
Copy Markdown
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd appreciate it if you could squash your commits too

View changes since this review

return self.span.shrink_to_hi();
}

let is_impl_generic = |par: &&GenericParam<'_>| match par.kind {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let is_impl_generic = |par: &&GenericParam<'_>| match par.kind {
let is_param_explicit = |par: &&GenericParam<'_>| match par.kind {

let parameter_type = if is_lifetime { "lifetime" } else { "type" };
if is_param_used {
let msg = format!(
"make use of the {} parameter `{}` in the `self` type",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"make use of the {} parameter `{}` in the `self` type",
"make use of the {} parameter `{}` in the `{}` type",

Can you get the name of the Self type from its DefId?

Applicability::MaybeIncorrect,
);
if suggestions.len() == 2 {
let msg = format!("or make use of it");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let msg = format!("or make use of it");
let msg = format!("or use it");

let msg2 = format!(
"and add it to the struct definition of {} as well since it's used in the body of the impl",
tcx.def_path_str(struct_def_id)
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably use a MultiSpan with the definition and the impl and emit a single suggestion for this instead of two distinct suggestions but that would need to be applied together

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And change the message to "use this type parameter in the type definition"

/// - `impl<'a> Struct { ... }` where `'a` is unused -> suggests removing `'a`.
/// - `impl<T> Struct { // T used in here }` where `T` is used in the body but not in the self type -> suggests adding `T` to the self type and struct definition.
/// - `impl<T> Struct { ... }` where the struct has a generic parameter with a default -> suggests adding `T` to the self type.
pub(crate) fn suggest_to_remove_or_use_generic(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add your own test file that tests all of these cases specifically, as well as where the type is defined in another crate, or where the type is generated from a macro.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants